﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using My.ELibrary.Business.Member;
using My.ELibrary.Model.Member;

using System.Collections.Generic;
public partial class Index_Login : System.Web.UI.UserControl
{
    private string m_id = string.Empty;
    protected string Id
    {
        get
        {
            if (ViewState["id"] != null)
            {
                return ViewState["id"].ToString();
            }
            else
            {
                return string.Empty;
            }
        }
        set
        {
            ViewState["id"] = value;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            table2.Attributes.Add("style", "display:none");
            btnLogin.Attributes.Add("onclick", "return chk();");
        }
    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (txtUserName.Text.Trim() != string.Empty && txtPwd.Text.Trim() != string.Empty)
        {

            List<ElibMemberModel> list = ElibMemberBLL.GetInstance().CheckUser(txtUserName.Text.Trim(), txtPwd.Text.Trim());
            if (list != null && list.Count > 0)
            {
                table1.Attributes.Add("style", "display:none");
                table2.Attributes.Add("style", "display:''");
                Id = list[0].Id.ToString();
                Label1.Text = Label1.Text + list[0].Name.ToString();
            }
            else
            {
                this.Page.RegisterStartupScript("", "<script language=JavaScript>alert('用户名或密码无效!')</script>");
            }
        }
    }
}
